<template>
  <div class="allsche-container">
    <el-row style="margin-top:20px">
            <el-col :span="17">
                <el-input v-model="keyword" placeholder="输入名称查询"></el-input>
                <div class="button-container">
      <el-button type="primary" icon="el-icon-edit" @click.native="gotoadd">新建</el-button>
    </div>

            </el-col>
            <br>
        </el-row>
        <el-row style="margin-top:20px" :gutter="12">
            <el-col :span="12" v-for="(item, i) in filteredData" :key="i" style="margin-top:20px;cursor:pointer">
                <el-card shadow="hover" @click.native="viewsche(i)">
                    <el-row>
                        <span style="font-weight:bold" class="rname">{{ item.rname }}</span>

                    </el-row>
                    <br>
                   
                </el-card>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { mapGetters } from 'vuex';
import { getAll } from '@/api/rs';
export default {
    name: 'allsche',
    created() {
        this.read();

    },
    computed: {
        ...mapGetters([
            'token',
        ])
        ,
        filteredData() {
            if (!this.keyword) {
                return this.rsData;

            }
            else
                // 使用关键词过滤数据
                return this.rsData.filter(item => {
                    // 根据实际情况修改过滤条件，比如匹配名称、ID等
                    return item.rname.includes(this.keyword);
                });
        },


  },

    data() {
        return {
            rsData:[],
            keyword: '',

        }
    },

    methods: {
        read() {
            getAll().then(response => {
                this.rsData = response.data.rs;
                //console.log(this.rsData[0].at.uid)
            }).catch(error => {
                console.log(error);
            })
        },

       
       viewsche(i) {
               this.$store.dispatch('user/setRId', this.rsData[i].rid).then(_ => {
                   this.$router.push('/SCEI/onesche')
               })
           
           //addposthistory(this.token,this.postData[i])

       },
       gotoadd(){
        this.$router.push('/SCEI/addsche')
       }
      }
}






</script>
<style lang="scss" scoped>
.allsche {
    &-container {
        margin: 30px;
    }
}

.rname {
    font-size: 20px;
    color: rgb(0, 0, 0);
    font-family: Arial, sans-serif;
}

.update {
    font-size: 15px;
    color: rgb(21, 21, 197);
    font-family: Arial, sans-serif;
}

.author {
    font-size: 13px;
}

.el-icon-view {
    font-size: 12px;
}

.el-icon-magic-stick {
    font-size: 12px;
}
.button-container {
  position: absolute;
  top: 20px; /* 距离顶部的距离 */
  right: 20px; /* 距离右边的距离 */
}
</style>